using UnityEngine;
using UnityEngine.UI;

public class ConnectionInfo : MonoBehaviour
{
	public InputField PortText;

	public InputField PaasswordText;

	public InputField ServerIPText;

	public InputField ServerNameText;

	public InputField ServerNameFillterText;

	public Text MapSelect;

	public Dropdown ViewSelect;

	private void Start()
	{
	}

	public void OnViewSelected(int type)
	{
		switch (type)
		{
		case 0:
			UnitZ.gameManager.GameViewType = GameView.Both;
			break;
		case 1:
			UnitZ.gameManager.GameViewType = GameView.FPS;
			break;
		case 2:
			UnitZ.gameManager.GameViewType = GameView.TPS;
			break;
		}
	}

	private void OnEnable()
	{
		if (!UnitZ.gameNetwork)
		{
			return;
		}
		if ((bool)MapSelect)
		{
			MainMenuManager mainMenuManager = (MainMenuManager)UnityEngine.Object.FindObjectOfType(typeof(MainMenuManager));
			LevelPreset level = UnitZ.levelManager.GetLevel(mainMenuManager.SceneStart);
			if (level != null)
			{
				MapSelect.text = level.SceneName;
			}
		}
		if ((bool)PortText)
		{
			PortText.text = UnitZ.gameNetwork.networkPort.ToString();
		}
		if ((bool)ServerIPText)
		{
			ServerIPText.text = UnitZ.gameNetwork.networkAddress;
		}
		if ((bool)ServerNameText)
		{
			ServerNameText.text = UnitZ.gameNetwork.matchName;
		}
		if ((bool)ServerNameFillterText)
		{
			ServerNameFillterText.text = UnitZ.gameNetwork.HostNameFillter;
		}
		if ((bool)PortText)
		{
			PortText.text = UnitZ.gameNetwork.networkPort.ToString();
		}
		if ((bool)PaasswordText)
		{
			PaasswordText.text = UnitZ.gameNetwork.HostPassword.ToString();
		}
	}

	//public void SetServerIP(InputField num)
	//{
	//	if ((bool)UnitZ.gameNetwork)
	//	{
	//		UnitZ.gameNetwork.networkAddress = num.text;
	//	}
	//}

	public void SetServerNameFillter(InputField num)
	{
		if ((bool)UnitZ.gameNetwork)
		{
			UnitZ.gameNetwork.HostNameFillter = num.text;
		}
	}

	public void SetServerName(InputField num)
	{
		if ((bool)UnitZ.gameNetwork)
		{
			UnitZ.gameNetwork.matchName = num.text;
		}
	}

	public void SetPassword(InputField num)
	{
		if ((bool)UnitZ.gameNetwork)
		{
			UnitZ.gameNetwork.HostPassword = num.text;
		}
	}

	public void SetPort(InputField num)
	{
		if ((bool)UnitZ.gameNetwork)
		{
			int result = UnitZ.gameNetwork.networkPort;
			if (int.TryParse(num.text, out result))
			{
				UnitZ.gameNetwork.networkPort = result;
			}
		}
	}
}
